home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / oop.swg / 0041_TurboVison BUTTONS.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-08-24  |  2.4 KB  |  89 lines

  1.  
  2. {
  3. Buttons are best done in TurboVision or ObjectWindows.  Re-read the
  4. sections dealing with the above in your manual and/or references.
  5.  
  6. If you want to use TurboVision (for the DOS environment), this is a unit
  7. for a derived object type I created to ease creation of dialog boxes.
  8. You might want to use it in addition to the TurboVision units:
  9. }
  10.  
  11. Unit XBoxes;
  12.  
  13. Interface
  14.  
  15. Uses Dialogs, Objects, Menus, Views;
  16.  
  17. Type
  18.   XDialog = Object(TDialog)
  19.      Procedure TxtEntry(x,y : Byte; txt : string; max : Byte);
  20.      Procedure MakeButton(x,y,w: Byte; Txt: string; cmd,mode: Word)
  21.      Procedure OKButton(x,y : Byte);
  22.      Procedure CancelButton(x,y : Byte);
  23.      Procedure Static(x,y : Byte; txt : string);
  24.      Procedure CheckBoxes(x,y,w,z : Byte; Items : PSItem);
  25.   End;
  26.   PXDialog = ^XDialog;
  27.  
  28. Implementation
  29.  
  30. Procedure XDialog.MakeButton(x,y,w: Byte; Txt: string; cmd, mode: Word)
  31. { Insert a button with the specified text, command, width, and mode at
  32.   the x,y coordinates in the dialog box }
  33.    R : TRect;
  34.    Temp : PButton;
  35. Begin;
  36.    R.Assign(x,y,x+w,y+2);
  37.    Temp := New(PButton,Init(R,Txt,cmd,mode));
  38.    Insert(Temp);
  39. End;
  40.  
  41. Procedure XDialog.OKButton(x,y : Byte);
  42. { Create and insert an 'OK' Button at x,y coordinates }
  43. Begin;
  44.    MakeButton(x,y,10,'~O~K',cmOK,bfDefault);
  45. End;
  46.  
  47. Procedure XDialog.CancelButton(x,y : Byte);
  48. { Create and insert a 'Cancel' button }
  49. Begin;
  50.    MakeButton(x,y,10,'Cancel',cmCancel,bfNormal);
  51. End;
  52.  
  53. Procedure XDialog.TxtEntry(x,y : Byte; txt : string; max : Byte);
  54. { Create a text entry line and label starting at x,y and expanding to
  55.   fill the rest of the line in the box. }
  56. Var
  57.    w : Byte;
  58.    ID : PView;
  59.    R : TRect;
  60. Begin;
  61.    GetExtent(R);
  62.    R.Assign(x+Length(txt)+2,y,R.B.X-2,y+1);
  63.    ID := New(PInputLine,Init(R,max));
  64.    Insert(ID);
  65.    R.Assign(x,y,x+Length(txt)+1,y+1);
  66.    Insert(New(PLabel,Init(R,txt,ID)));
  67. End;
  68.  
  69. Procedure XDialog.Static(x,y : Byte; txt : string);
  70. { Static text at x,y }
  71. Var
  72.    R : TRect;
  73. Begin;
  74.    R.Assign(x,y,x+Length(txt)+1,y+1);
  75.    Insert(New(PStaticText,Init(R,txt)));
  76. End;
  77.  
  78. Procedure XDialog.CheckBoxes(x,y,w,z : Byte; Items : PSItem);
  79. { Insert check boxes for cluster 'Items' at x,y with a maximum width of
  80.   w and a total of z items. }
  81. Var
  82.    R : TRect;
  83. Begin;
  84.    R.Assign(x,y,x+(w+3)+1,y+z+1);
  85.    Insert(New(PCheckBoxes,Init(R,Items)));
  86. End;
  87.  
  88. End.
  89.